package com.example.baseapp.service.impl;

import com.example.baseapp.entity.Dish;
import com.example.baseapp.repository.DishRepository;
import com.example.baseapp.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DishServiceImpl implements DishService {
    
    @Autowired
    private DishRepository dishRepository;
    
    @Override
    public List<Dish> getAllDishes() {
        return dishRepository.findAll();
    }
    
    @Override
    public List<Dish> getDishesByCategory(Long categoryId) {
        return dishRepository.findByCategoryIdOrderByCreateTimeDesc(categoryId);
    }
    
    @Override
    public List<Dish> getAllActiveDishes() {
        return dishRepository.findAllActiveOrderByCategory();
    }
    
    @Override
    public List<Dish> getActiveDishesByCategory(Long categoryId) {
        return dishRepository.findByCategoryIdAndStatusOrderByCreateTimeDesc(categoryId, 1);
    }
} 